package six.test;

public class MyObject {

	// 饿汉模式

	// private static MyObject myObject = new MyObject();
	//
	// private MyObject(){}
	//
	// public static MyObject getInstance(){
	// return myObject;
	// }

	// 懒汉模式

	private static MyObject myObject;

	private MyObject() {
	}

	public static MyObject getInstance() {
		try {
			if (myObject != null) {
			} else {
				Thread.sleep(3000);
				myObject = new MyObject();
			}

		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return myObject;
	}

}
